<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class track extends CI_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->helper('url');
		$this->load->model('task_mod','tk');
		$this->load->model('gs_mod','gs');
		$this->load->model('Track_mod','T');
	}
	
	function Addtrack()
	{
		$data['gsid'] = $this->input->post('gsid');
		$cs['uid'] = $data['uid'] = $this->session->userdata('u_id');
		$data['cid'] = $this->input->post('cid');
		$data['tid'] = 0;
		$data['date'] = time();
		$cs['t_name'] = $data['content'] = $this->input->post('gzcontent');
		$cs['type'] = 2;
		$cs['status'] = 1;
		$cs['t_mtime'] = date('Y-m-d H:i:s',time());
		$cs['t_completedtime'] = date('Y-m-d H:i:s',time());
		$this->T->InsertTask($cs);
		$this->T->InsertTrack($data);
		die($this->ajaxResp($data['gsid']));
	}
	
	function ajaxResp($gsid)
	{
		$trackList = $this->T->getgsTrackBygsid($gsid);
		$str = "<li>
				<div class='FL check_cp digestImg m-t5'><a href='#'></a></div>
				<div class=\"FL digest m-l20\">
				<div class=\"date m-t5\">
					<span class=\"FB FL\">".$trackList[0]['content']."</span>
					<span class=\"FR hidden\">
						<a href=\"#\" class=\"FR\">Go to note</a>
						<a href=\"#\" class=\"triangle FR m-r15\">file | this</a>
					</span>				
				</div>
				<div class=\"clear\"></div>
				<div class=\"writer m-t5\">
				<font color=\"red\">[".$trackList[0]['m_username']."]</font>
				-><font color=\"blue\">[".$trackList[0]['name']."]</font>
				</div>
				<p class=\"\" style=\"margin-top:20px\">".date('Y-m-d H:i:s',$trackList[0]['date'])."</p>
				</div>
				<div class=\"clear\"></div>
				</li>";
				
				
		return $str;
	}
}
?>